import type { BasicColumn, FormSchema } from '@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import * as selfFunc from './spu.func';
import { ref } from 'vue';

export const searchFormSchema: FormSchema[] = [
  // {
  //   field: "title",
  //   label: "主标题",
  //   component: "Jcheckbox",
  //   colProps: { span: 8 },
  // },
];

export const columns: BasicColumn[] = [
  {
    title: '商品主标题',
    dataIndex: 'title',
    align: 'center',
  },
  {
    title: '商品编码',
    dataIndex: 'spuCode',
    align: 'center',
  },
  {
    title: '商品类型',
    dataIndex: 'spuType',
    align: 'center',
    // customRender: render.renderSpuType,
  },
  {
    title: '助记码',
    dataIndex: 'pinyin',
    align: 'center',
  },
  {
    title: '商品主图',
    dataIndex: 'firstImgId',
    align: 'center',
    customRender: render.renderImg,
  },
  {
    title: '轮播图',
    dataIndex: 'lunboImgIds',
    align: 'center',
    customRender: render.renderImg,
  },
  {
    title: '结算单位',
    dataIndex: 'settleUnit',
    align: 'center',
  },
  {
    title: '计价方式',
    dataIndex: 'priceMode',
    align: 'center',
    // customRender: render.renderPriceMode,
  },
  
  {
    title: '有效期(天)',
    dataIndex: 'effectivePeriod',
    align: 'center',
    
  },
  {
    title: '提前预警天数',
    dataIndex: 'warnDays',
    align: 'center',
  },
  
  {
    title: '上下架状态',
    dataIndex: 'status',
    align: 'center',
  },
  {
    title: '规格类型',
    dataIndex: 'specType',
    align: 'center',
    // customRender: render.renderSpuSpecType,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    align: 'center',
    customRender: render.renderDate,
  },
  {
    title: '更新时间',
    dataIndex: 'updateTime',
    align: 'center',
    customRender: render.renderDate,
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input',
  },
  {
    label: '商品主标题',
    field: 'title',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '商品副标题',
    field: 'subTitle',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '最末级后台分类id',
    field: 'backendCateId',
    colProps: {
      span: 12,
    },
    component: 'JDictSelectTag',
    componentProps: {
      type: 'select',
    },
  },
  {
    label: '商品编码',
    field: 'spuCode',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '商品类型',
    field: 'spuType',
    colProps: {
      span: 12,
    },
    component: 'JDictSelectTag',
    componentProps: selfFunc.renderSpuTypeCompProps,
  },
  {
    label: '助记码',
    field: 'pinyin',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '商品主图',
    field: 'firstImgId',
    colProps: {
      span: 12,
    },
    component: 'JImageUpload',
    componentProps: {
      bizPath: 'demo/spu',
      fileType: 'image',
    },
  },
  /*  {
    label: '轮播图',
    field: 'lunboImgIds',
    colProps: {
      span: 12,
    },
    component: 'JImageUpload',
    componentProps: {
      bizPath: 'demo/spu',
      fileType: 'image',
      fileMax:5,
    },
  }, */
  {
    label: '结算单位',
    field: 'settleUnit',
    colProps: {
      span: 12,
    },
    component: 'Input',
  },
  {
    label: '计价方式',
    field: 'priceMode',
    colProps: {
      span: 12,
    },
    component: 'JDictSelectTag',
    componentProps: {
      type: 'select',
      dictCode: 'price_mode',
    },
  },
  {
    label: '有效期',
    field: 'effectivePeriod',
    colProps: {
      span: 12,
    },
    component: 'InputNumber',
    suffix: '天',
  },
  {
    label: '提前预警天数',
    field: 'warnDays',
    colProps: {
      span: 12,
    },
    component: 'InputNumber',
  },

  {
    label: '规格类型',
    field: 'specType',
    colProps: {
      span: 12,
    },
    component: 'JDictSelectTag',
    componentProps: {
      type: 'radio',
      dictCode: 'spu_spec_type',
    },
  },

  {
    label: '规格',
    field: 'multiSpecId',
    colProps: {
      span: 24,
    },
    component: 'Input',
    slot: 'multiSpecSlot',
  },
];

export const sourceAttribute = ref<any[]>([]);
export const attribute = ref<any[]>([]);
export const sku = ref<any[]>([]);
export const spuId = ref<any>('');
export const multiSpecId = ref<any>('');
